/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practice;

import java.io.IOException;
import static chanlib.Chan_IO.*;

/**
 * @author robit
 */
public class NumberGame{
    /*
      All neccesary to be defined
      including:
      variable, inner class
    */
    // static int A;
    // static void B();
    // static class C
    static boolean winning(int A,int B){
        if(B==0)return true;
        if(A>=2*B)return true;
        else return !winning(B,A-B);
    }
    /*
       One calculation fits all of the cases.
    */
    static void preReckon(){
        return;
    }

    /*
      calculate the answer
    */
    private static void reckon(int line) {
        int A1=Int(),A2=Int(),B1=Int(),B2=Int();
        long count=0;
        double golden=(1+Math.sqrt(5))/2;
        int lower;
        for(int b=B1;b<=B2;b++){
            lower=(int)(b*golden)+1;
            if(lower<A1)count+=A2-A1+1;
            else if(lower<=A2)count+=A2-lower+1;
        }            
        for(int a=A1;a<=A2;a++){
            lower=(int)(a*golden)+1;
            if(lower<B1)count+=B2-B1+1;
            else if(lower<=B2)count+=B2-lower+1;
        }
          
        String ans=String.valueOf(count);
        String output=String.format("Case #%d: %s",line,ans);
        writeln(output, OUTFILE);
        //writeln(String.format("N=%d K=%d\n%s", N, K, ans),ANALFILE);
        //println(output);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        /*
           Pre-computing for all cases
        */

        // Just in case!
        //preReckon();
        //while((char)read()!='P');

        /*
          Input-output
        */
        boolean test=false;
        boolean small=false;
        String prob="C";
        String filename;
        if(test) filename="test";
        else{
            if(small) filename=prob+"-small-practice";
            else filename=prob+"-large-practice";
        }
        try {
            /*
               Init IO,plus determination of input line number
             */
            int lineNums = initFileIO(filename);
            for (int i = 1; i <= lineNums; i++) {
                reckon(i);
            }
        } finally {
            endIO();
        }
    }

}
